home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / dev / c / PhoneLogDevKit.lha / PhoneLog / src / PhoneLogGenerator.c < prev    next >
Encoding:
Text File  |  1996-03-16  |  19.7 KB  |  753 lines

  1. /* Copyright © 1996 Kai Hofmann. All rights reserved.
  2. ******* PhoneLog/--history-- ************************************************
  3. *
  4. *   NAME
  5. *    history -- This is the development history of the PhoneLog library
  6. *
  7. *   VERSION
  8. *    $VER: PhoneLog 1.1 (15.03.96)
  9. *
  10. *   HISTORY
  11. *    18.02.1996 -    Concept
  12. *    19.02.1996 -    Implementation
  13. *    05.03.1996 -    Writing Autodocs
  14. *    06.03.1996 -    Improving generator and parser
  15. *    07.03.1996 -    Wrinting Autodocs and improvements for the parser
  16. *    15.03.1996 -    Fixing bugs - now the date/time-format is in
  17. *            correct ISO8601 format
  18. *            closing SGML element now correctly using '/' instead
  19. *            of '\'
  20. *            Better scanner - now supports empty elements
  21. *            Changed SGML DTD - HOSTNAME ist now optional
  22. *            Parser now initialize and insert entry and mark
  23. *            correctly
  24. *            Parser now checks strings for length limitation
  25. *
  26. *****************************************************************************
  27. *
  28. *
  29. */
  30.  
  31. /*
  32. ******* PhoneLog/--release-- ************************************************
  33. *
  34. *   NAME
  35. *    release -- This is the release history of the PhoneLog library
  36. *
  37. *   RELEASE
  38. *    08.03.1996 : V1.0 -    First release on Aminet
  39. *    15.03.1996 : v1.1 -    Second Aminet release
  40. *
  41. *****************************************************************************
  42. *
  43. *
  44. */
  45.  
  46. /*
  47. ******* PhoneLog/--todo-- ***************************************************
  48. *
  49. *   NAME
  50. *    todo -- This is the 'To-Do' list of the PhoneLog library
  51. *
  52. *   TODO
  53. *    Nothing at the moment
  54. *
  55. *****************************************************************************
  56. *
  57. *
  58. */
  59.  
  60. /*
  61. ******* PhoneLog/--announce-- ***********************************************
  62. *
  63. *   TITLE
  64. *    PhoneLog Developer Kit
  65. *
  66. *   VERSION
  67. *    1.1
  68. *
  69. *   RELEASE DATE
  70. *    15.03.1996
  71. *
  72. *   AUTHOR
  73. *    Kai Hofmann (i07m@zfn.uni-bremen.de)
  74. *                (http://www.informatik.uni-bremen.de/~i07m)
  75. *
  76. *   DESCRIPTION
  77. *    Generator and parser for programs that want to write and read log
  78. *    file entries about modem connections in a standard SGML format.
  79. *    Full ANSI-C/C++ source code included.
  80. *
  81. *   NEW FEATURES
  82. *    - Important bug fixes
  83. *    - Improved code
  84. *
  85. *   SPECIAL REQUIREMENTS
  86. *    ANSI-C or/and C++ Compiler.
  87. *
  88. *   AVAILABILITY
  89. *    ftp://wuarchive.wustl.edu/pub/aminet/dev/c/PhoneLogDevKit.lha
  90. *    And all other Aminet sites.
  91. *
  92. *   PRICE
  93. *    For NON-COMMERCIAL USE this is Giftware!
  94. *    (Non-commercial includes Giftware and Shareware!)
  95. *
  96. *    Permission for COMMERCIAL USE is only given by an extra available
  97. *    commercial license that must be validated!
  98. *    Contact me directly for this license, because it will be individually
  99. *    handed out per your needs!
  100. *
  101. *    But in both cases you have to follow the two guidelines below:
  102. *
  103. *    1) You "must" send me a full version of your product at no cost
  104. *       including free updates!
  105. *
  106. *   DISTRIBUTION
  107. *    You can copy and distribute this source code as long as you do not
  108. *    take more than $5 for one disk or $40 for one CD!
  109. *
  110. *****************************************************************************
  111. *
  112. *
  113. */
  114.  
  115. /*
  116. ******* PhoneLog/--compiling-- **********************************************
  117. *
  118. *   NAME
  119. *    compiling -- Specials for compiling the PhoneLog library
  120. *
  121. *   COMPILING
  122. *    - You could compile this code as normal C or as C++
  123. *    - You need only the follwoing files to include:
  124. *      PhoneLog.h, PhoneLogGenerator.h, PhoneLogParserInterface.h
  125. *      If you want to modifiy the scanner and/or parser, you need the
  126. *      following software: Aminet:dev/misc/Toolbox.lha to translate the
  127. *      .rex and .lalr file into C code!
  128. *
  129. *****************************************************************************
  130. *
  131. *
  132. */
  133.  
  134. /*
  135. ******* PhoneLog/--background-- *********************************************
  136. *
  137. *   NAME
  138. *    PhoneLog -- Write and read entries to/from a log file (V33)
  139. *
  140. *   FUNCTION
  141. *    This module has been designed to become a useful and portable library
  142. *    and to help developers to write and read entries to/from a log file
  143. *    in a standard SGML format.
  144. *
  145. *   NOTES
  146. *    It seems that there was no standard for log files that are used
  147. *    to log modem connections etc.
  148. *    So I decided to create a standard based on SGML, because SGML
  149. *    uses the ASCII characterset as base, so it can be used on every
  150. *    platform. On the other hand SGML gives the log file a real structure
  151. *    that is defined by the SGML DTD.
  152. *    By supporting this standard with your software you give the user the
  153. *    possibility to create or evaluate log files with software from
  154. *    different platforms; and you get a standard that is easily extended
  155. *    if a need occurs.
  156. *
  157. *    SGML : Standard Generalized Markup Language
  158. *    DTD  : Document Type Definition
  159. *
  160. *    (English) Books which were consulted in creating this library:
  161. *        The SGML Handbook
  162. *        Charles F. Goldfarb
  163. *        First Edition
  164. *        Oxford University Press, Walton Street, Oxford (USA) 1990
  165. *        ISBN 0-19-853737-9
  166. *
  167. *   COPYRIGHT
  168. *    This software is copyright 1996 by Kai Hofmann.
  169. *    All rights reserved!
  170. *
  171. *    - Permission for COMMERCIAL USE is only given by an extra available
  172. *      commercial license that must be validated!
  173. *      Contact me directly for this license, because it will be
  174. *      individually handed out per your needs!
  175. *
  176. *    - Permission is hereby granted, without written agreement and without
  177. *      license, to USE this software and its documentation for any
  178. *      NON-COMMERCIAL purpose, provided that the above copyright notice
  179. *      and the following paragraph appear in all copies of this software
  180. *      (Non-commercial includes Giftware and Shareware!).
  181. *
  182. *    - THERE IS *NO* PERMISSION GIVEN TO REDISTRIBUTE THIS SOFTWARE IN A
  183. *      MODIFIED FORM!
  184. *
  185. *      You "must" send me a full version of your product at no cost
  186. *      including free updates!
  187. *      Extra money is welcome (For Bank Account see below - but *ONLY*
  188. *      send in DM to this Bank Account!).
  189. *
  190. *   DISCLAIMER
  191. *    THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
  192. *    APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  193. *    HOLDER AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
  194. *    WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
  195. *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  196. *    A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
  197. *    PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
  198. *    DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  199. *    CORRECTION.
  200. *
  201. *    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  202. *    WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY REDISTRIBUTE
  203. *    THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  204. *    INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
  205. *    ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING
  206. *    BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
  207. *    LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
  208. *    TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
  209. *    PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  210. *
  211. *    THE AUTHOR HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
  212. *    UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  213. *
  214. *   DISTRIBUTION
  215. *    Permission is hereby granted, without written agreement and without
  216. *    license or royalty fees, to copy and distribute this software and its
  217. *    documentation for any purpose, provided that the above copyright
  218. *    notice and the following paragraphs appear in all copies of this
  219. *    software, to:
  220. *    - All who will distribute this software for free!
  221. *    - All free accessible INTERNET servers and PHONE boxes!
  222. *    - All Aminet sites
  223. *    - All SimTel sites
  224. *    - Fred Fish for his great Amiga-Software-Library
  225. *    - The German SAAR AG PD-Library
  226. *    - All others who do NOT take more than $5.- for one disk that
  227. *      includes this software!
  228. *    - ALL others who do NOT take more than $40.- for one CD that includes
  229. *      this software!
  230. *
  231. *   ADDITIONAL INFORMATIONS
  232. *    I have tried to make portable/useful and I hope bugfree software
  233. *    for eternity :)
  234. *    So I hope you will pay a fee for this.
  235. *
  236. *    Kindly send US - dollars to a friend of mine in the USA who will
  237. *    forward it to me in a timely manner.  Please send checks or money
  238. *    orders only.
  239. *    Contact me via email for more details!
  240. *
  241. *   AUTHOR
  242. *    Kai Hofmann
  243. *    Arberger Heerstraße 92
  244. *    28307 Bremen
  245. *    Germany
  246. *
  247. *    Phone: (+49)-(0)421/480780
  248. *           (Remember that my parents don't speak english!)
  249. *    EMail: i07m@zfn.uni-bremen.de
  250. *           i07m@informatik.uni-bremen.de
  251. *    IRC  : PowerStat@#AmigaGer
  252. *    WWW  : http://www.informatik.uni-bremen.de/~i07m
  253. *
  254. *    Bank account : 1203 7503
  255. *    Account owner: Kai Hofmann
  256. *    Bank code    : 290 501 01
  257. *    Bank name    : Sparkasse in Bremen/Germany
  258. *
  259. *    THANKS
  260. *    Thank you's are going to the following people:
  261. *    Rita Reichl        - For correcting my English.
  262. *    James Cooper and the
  263. *    other Amiga people at
  264. *    SAS Intitute        - For spending their unpaid free time with
  265. *                  continuation of the Amiga SAS C/C++
  266. *                  support :)
  267. *
  268. *****************************************************************************
  269. *
  270. *
  271. */
  272.  
  273.  
  274.  #include "PhoneLogGenerator.h"
  275.  #include "PhoneLog.h"
  276.  #include <stdio.h>
  277.  
  278.  
  279.  #define PROGNAME    "MUIBill" /* Please use the name of your program here!     */
  280.  #define PROGVERSION    0         /* Please use the version of your program here!  */
  281.  #define PROGREVISION    1         /* Please use the revision of your program here! */
  282.  #define MARKNAME    "LogScan"
  283.  
  284.  
  285.  FILE *OpenPhoneLog(const char *const name)
  286.  
  287. /*
  288. ******* PhoneLogGenerator/OpenPhoneLog **************************************
  289. *
  290. *   NAME
  291. *    OpenPhoneLog -- Opens a log file for write operations (V33)
  292. *
  293. *   SYNOPSIS
  294. *    file = OpenPhoneLog(name);
  295. *
  296. *    FILE *OpenPhoneLog(const char *const name);
  297. *
  298. *   FUNCTION
  299. *    Opens a log file for appending new entries. If the log file doesn't
  300. *    exist, a new one will be created.
  301. *
  302. *   INPUTS
  303. *    name - The name of the log file.
  304. *
  305. *   RESULT
  306. *    file - stdio.h file descriptor for a level 2 file or NULL if an error
  307. *        occurs.
  308. *
  309. *   EXAMPLE
  310. *    ...
  311. *    FILE *file;
  312. *
  313. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  314. *    ...
  315. *    ClosePhoneLog(file);
  316. *    ...
  317. *
  318. *   NOTES
  319. *    None
  320. *
  321. *   BUGS
  322. *    No known bugs.
  323. *
  324. *   SEE ALSO
  325. *    ClosePhoneLog(),WritePhoneLogStartEntry(),WritePhoneLogEndEntry(),
  326. *    WritePhoneLogEntry(),WritePhoneLogMark()
  327. *
  328. *****************************************************************************
  329. *
  330. *
  331. */
  332.  
  333.   {
  334.    FILE *file;
  335.  
  336.    file = fopen(name,"a");
  337.    if (file != NULL)
  338.     {
  339.      fpos_t fpos;
  340.  
  341.      /*result=*/ fgetpos(file,&fpos);
  342.      if (fpos == 0)
  343.       {
  344.        fprintf(file,"<PHONELOG");
  345.        fprintf(file," version=1 revision=1");
  346.        fprintf(file,">\n");
  347.       }
  348.     }
  349.    return(file);
  350.   }
  351.  
  352.  
  353.  void ClosePhoneLog(FILE *const file)
  354.  
  355. /*
  356. ******* PhoneLogGenerator/ClosePhoneLog *************************************
  357. *
  358. *   NAME
  359. *    ClosePhoneLog -- Close a log file (V33)
  360. *
  361. *   SYNOPSIS
  362. *    ClosePhoneLog(file);
  363. *
  364. *    void ClosePhoneLog(FILE *const file);
  365. *
  366. *   FUNCTION
  367. *    Close a log file opened by OpenPhoneLog().
  368. *
  369. *   INPUTS
  370. *    file - The stdio.h file descriptor for a level 2 file that you got
  371. *        from OpenPhoneLog().
  372. *
  373. *   RESULT
  374. *    None
  375. *
  376. *   EXAMPLE
  377. *    ...
  378. *    FILE *file;
  379. *
  380. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  381. *    ...
  382. *    ClosePhoneLog(file);
  383. *    ...
  384. *
  385. *   NOTES
  386. *    None
  387. *
  388. *   BUGS
  389. *    No known bugs.
  390. *
  391. *   SEE ALSO
  392. *    OpenPhoneLog(),WritePhoneLogStartEntry(),WritePhoneLogEndEntry(),
  393. *    WritePhoneLogEntry(),WritePhoneLogMark()
  394. *
  395. *****************************************************************************
  396. *
  397. *
  398. */
  399.  
  400.   {
  401.    fclose(file);
  402.   }
  403.  
  404.  
  405.  void WritePhoneLogStartEntry(FILE *const file, const struct PhoneLogEntry *const item)
  406.  
  407. /*
  408. ******* PhoneLogGenerator/WritePhoneLogStartEntry ***************************
  409. *
  410. *   NAME
  411. *    WritePhoneLogStartEntry -- Write the start to a log file (V33)
  412. *
  413. *   SYNOPSIS
  414. *    WritePhoneLogStartEntry(file, item);
  415. *
  416. *    void WritePhoneLogStartEntry(FILE *const file,
  417. *        const struct PhoneLogEntry *const item);
  418. *
  419. *   FUNCTION
  420. *    Write the start data for a connection to a log file opened by
  421. *    OpenPhoneLog().
  422. *
  423. *   INPUTS
  424. *    file - The stdio.h file descriptor for a level 2 file that you got
  425. *        from OpenPhoneLog().
  426. *    item - PhoneLogEntry structure. You must fill in following fields:
  427. *        Number, StartDay, StartMonth, StartYear, StartHour,
  428. *        StartMin, StartSec.
  429. *        The fields Name and Reason are optional and will only be written
  430. *        if the string length is greater than 0.
  431. *
  432. *   RESULT
  433. *    None
  434. *
  435. *   EXAMPLE
  436. *    ...
  437. *    FILE *file;
  438. *    struct PhoneLogEntry item;
  439. *
  440. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  441. *    ...
  442. *    strcpy(item.Number,"1234567890");
  443. *    strcpy(item.Name,"University");
  444. *    item.StartDay = 5;
  445. *    item.StartMonth = 3;
  446. *    item.StartYear = 1996; \* NOT 96! *\
  447. *    item.StartHour = 12;
  448. *    item.StartMin = 3;
  449. *    item.StartSec = 0;
  450. *    WritePhoneLogStartEntry(file,item);
  451. *    ...
  452. *    ClosePhoneLog(file);
  453. *    ...
  454. *
  455. *   NOTES
  456. *    Set Reason[0] = '\0' if you not want that this will be written to
  457. *    the log file.
  458. *
  459. *   BUGS
  460. *    No known bugs.
  461. *
  462. *   SEE ALSO
  463. *    OpenPhoneLog(),ClosePhoneLog(),WritePhoneLogEndEntry(),
  464. *    WritePhoneLogEntry(),WritePhoneLogMark()
  465. *
  466. *****************************************************************************
  467. *
  468. *
  469. */
  470.  
  471.   {
  472.    fprintf(file,"\n<ENTRY>\n");
  473.    fprintf(file,"  <HOST>\n");
  474.    fprintf(file,"    <NUMBER>");
  475.    fprintf(file,"%s",item->Number);
  476.    fprintf(file,"</NUMBER>\n");
  477.    if (item->Name[0] != '\0')
  478.     {
  479.      fprintf(file,"    <HOSTNAME>");
  480.      fprintf(file,"%s",item->Name);
  481.      fprintf(file,"</HOSTNAME>\n");
  482.     }
  483.    if (item->Reason[0] != '\0')
  484.     {
  485.      fprintf(file,"    <REASON>");
  486.      fprintf(file,"%s",item->Reason);
  487.      fprintf(file,"</REASON>\n");
  488.     }
  489.    fprintf(file,"  </HOST>\n");
  490.    fprintf(file,"  <START>\n");
  491.    fprintf(file,"    <DATE>");
  492.    fprintf(file,"%04d-%02hu-%02hu",item->StartYear,item->StartMonth,item->StartDay);
  493.    fprintf(file,"</DATE>\n");
  494.    fprintf(file,"    <TIME>");
  495.    fprintf(file,"%02hu:%02hu:%02hu",item->StartHour,item->StartMin,item->StartSec);
  496.    fprintf(file,"</TIME>\n");
  497.    fprintf(file,"  </START>\n");
  498.   }
  499.  
  500.  
  501.  void WritePhoneLogEndEntry(FILE *const file, const struct PhoneLogEntry *const item)
  502.  
  503. /*
  504. ******* PhoneLogGenerator/WritePhoneLogEndEntry *****************************
  505. *
  506. *   NAME
  507. *    WritePhoneLogEndEntry -- Write the end to a log file (V33)
  508. *
  509. *   SYNOPSIS
  510. *    WritePhoneLogEndEntry(file, item);
  511. *
  512. *    void WritePhoneLogEndEntry(FILE *const file,
  513. *        const struct PhoneLogEntry *const item);
  514. *
  515. *   FUNCTION
  516. *    Write the end data for a connection to a log file opened by
  517. *    OpenPhoneLog() after you have used WritePhoneLogStartEntry()!
  518. *
  519. *   INPUTS
  520. *    file - The stdio.h file descriptor for a level 2 file that you got
  521. *        from OpenPhoneLog().
  522. *    item - PhoneLogEntry structure. You must fill in following fields:
  523. *        EndDay, EndMonth, EndYear, EndHour, EndMin, EndSec
  524. *        If you want you can optionally fill in the fields:
  525. *        Hours, Mins, Secs
  526. *
  527. *   RESULT
  528. *    None
  529. *
  530. *   EXAMPLE
  531. *    ...
  532. *    FILE *file;
  533. *    struct PhoneLogEntry item;
  534. *
  535. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  536. *    ...
  537. *    item.EndDay = 5;
  538. *    item.EndMonth = 3;
  539. *    item.EndYear = 1996; \* NOT 96! *\
  540. *    item.EndHour = 12;
  541. *    item.EndMin = 17;
  542. *    item.EndSec = 0;
  543. *    WritePhoneLogEndEntry(file,item);
  544. *    ...
  545. *    ClosePhoneLog(file);
  546. *    ...
  547. *
  548. *   NOTES
  549. *    If you want to write the optional fields Hours, Mins, Secs to the log
  550. *    file, please remove the second comment from the source code!
  551. *    If you want that EndDay, EndMonth and EndYear will only be written
  552. *    to the log file if they are different to the start date, then please
  553. *    remove the first comment from the source code, but keep in mind
  554. *    that you now must fill the structure with StartDay, StartMonth and
  555. *    StartYear too!
  556. *
  557. *   BUGS
  558. *    No known bugs.
  559. *
  560. *   SEE ALSO
  561. *    OpenPhoneLog(),ClosePhoneLog(),WritePhoneLogStartEntry(),
  562. *    WritePhoneLogEntry(),WritePhoneLogMark()
  563. *
  564. *****************************************************************************
  565. *
  566. *
  567. */
  568.  
  569.   {
  570.    fprintf(file,"  <END>\n");
  571.    /*if (StartDate != EndDate)*/
  572.     {
  573.      fprintf(file,"    <DATE>");
  574.      fprintf(file,"%04d-%02hu-%02hu",item->EndYear,item->EndMonth,item->EndDay);
  575.      fprintf(file,"</DATE>\n");
  576.     }
  577.    fprintf(file,"    <TIME>");
  578.    fprintf(file,"%02hu:%02hu:%02hu",item->EndHour,item->EndMin,item->EndSec);
  579.    fprintf(file,"</TIME>\n");
  580.    fprintf(file,"  </END>\n");
  581.    /*
  582.    if ((item->Hours > 0) || (item->Mins > 0) || (item->Secs > 0))
  583.     {
  584.      fprintf(file,"  <PERIOD>");
  585.      if (item->Hours > 0)
  586.       {
  587.        fprintf(file,"%huH",item->Hours);
  588.       }
  589.      if (item->Mins > 0)
  590.       {
  591.        fprintf(file,"%02huM",item->Mins);
  592.       }
  593.      if (item->Secs > 0)
  594.       {
  595.        fprintf(file,"%02huS",item->Secs);
  596.       }
  597.      fprintf(file,"</PERIOD>\n");
  598.     }
  599.    */
  600.    fprintf(file,"</ENTRY>\n");
  601.   }
  602.  
  603.  
  604.  void WritePhoneLogEntry(FILE *const file, const struct PhoneLogEntry *const item)
  605.  
  606. /*
  607. ******* PhoneLogGenerator/WritePhoneLogEntry ********************************
  608. *
  609. *   NAME
  610. *    WritePhoneLogEntry -- Write a full entry to a log file (V33)
  611. *
  612. *   SYNOPSIS
  613. *    WritePhoneLogEntry(file, item);
  614. *
  615. *    void WritePhoneLogEntry(FILE *const file,
  616. *        const struct PhoneLogEntry *const item);
  617. *
  618. *   FUNCTION
  619. *    Write a full entry for a connection to a log file opened by
  620. *    OpenPhoneLog().
  621. *
  622. *   INPUTS
  623. *    file - The stdio.h file descriptor for a level 2 file that you got
  624. *        from OpenPhoneLog().
  625. *    item - PhoneLogEntry structure. You must fill in following fields:
  626. *        Number, Name, StartDay, StartMonth, StartYear, StartHour,
  627. *        StartMin, StartSec, EndDay, EndMonth, EndYear, EndHour, EndMin,
  628. *        EndSec
  629. *        If you want you can optionally fill in the fields:
  630. *        Hours, Mins, Secs
  631. *
  632. *   RESULT
  633. *    None
  634. *
  635. *   EXAMPLE
  636. *    ...
  637. *    FILE *file;
  638. *    struct PhoneLogEntry item;
  639. *
  640. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  641. *    ...
  642. *    strcpy(item.Number,"1234567890");
  643. *    strcpy(item.Name,"University");
  644. *    item.StartDay = 5;
  645. *    item.StartMonth = 3;
  646. *    item.StartYear = 1996; \* NOT 96! *\
  647. *    item.StartHour = 12;
  648. *    item.StartMin = 3;
  649. *    item.StartSec = 0;
  650. *    item.EndDay = 5;
  651. *    item.EndMonth = 3;
  652. *    item.EndYear = 1996; \* NOT 96! *\
  653. *    item.EndHour = 12;
  654. *    item.EndMin = 17;
  655. *    item.EndSec = 0;
  656. *    WritePhoneLogEntry(file,item);
  657. *    ...
  658. *    ClosePhoneLog(file);
  659. *    ...
  660. *
  661. *   NOTES
  662. *    If you want to write the optional fields Hours, Mins, Secs to the log
  663. *    file, please remove the second comment from the source code of the
  664. *    function WritePhoneLogEndEntry().
  665. *    If you want that EndDay, EndMonth and EndYear will only be written
  666. *    to the log file if they are different to the start date, then please
  667. *    remove the first comment from the source code of the function
  668. *    WritePhoneLogEndEntry().
  669. *
  670. *   BUGS
  671. *    No known bugs.
  672. *
  673. *   SEE ALSO
  674. *    OpenPhoneLog(),ClosePhoneLog(),WritePhoneLogStartEntry(),
  675. *    WritePhoneLogEndEntry(),WritePhoneLogMark()
  676. *
  677. *****************************************************************************
  678. *
  679. *
  680. */
  681.  
  682.   {
  683.    WritePhoneLogStartEntry(file,item);
  684.    WritePhoneLogEndEntry(file,item);
  685.   }
  686.  
  687.  
  688.  void WritePhoneLogMark(FILE *const file)
  689.  
  690. /*
  691. ******* PhoneLogGenerator/WritePhoneLogMark *********************************
  692. *
  693. *   NAME
  694. *    WritePhoneLogMark -- Write a mark to a log file (V33)
  695. *
  696. *   SYNOPSIS
  697. *    WritePhoneLogMark(file);
  698. *
  699. *    void WritePhoneLogMark(FILE *const file);
  700. *
  701. *   FUNCTION
  702. *    Write a mark to a log file opened by OpenPhoneLog().
  703. *
  704. *   INPUTS
  705. *    file - The stdio.h file descriptor for a level 2 file that you got
  706. *        from OpenPhoneLog().
  707. *
  708. *   RESULT
  709. *    None
  710. *
  711. *   EXAMPLE
  712. *    ...
  713. *    FILE *file;
  714. *
  715. *    file = OpenPhoneLog("AmiTCP:log/AmiLog.log");
  716. *    ...
  717. *    WritePhoneLogMark(file);
  718. *    ...
  719. *    ClosePhoneLog(file);
  720. *    ...
  721. *
  722. *   NOTES
  723. *    This function is for programs that evaluate log files only!
  724. *    After such a program has parsed the log file it can write a mark,
  725. *    so it knows the next time it parses the log file which data is
  726. *    already known.
  727. *
  728. *   BUGS
  729. *    No known bugs.
  730. *
  731. *   SEE ALSO
  732. *    OpenPhoneLog(),ClosePhoneLog(),WritePhoneLogStartEntry(),
  733. *    WritePhoneLogEndEntry(),WritePhoneLogEntry()
  734. *
  735. *****************************************************************************
  736. *
  737. *
  738. */
  739.  
  740.   {
  741.    fprintf(file,"\n<MARK>\n");
  742.    fprintf(file,"  <PROGRAM ");
  743.    fprintf(file,"version=%u ",PROGVERSION);
  744.    fprintf(file,"revision=%u",PROGREVISION);
  745.    fprintf(file,">");
  746.    fprintf(file,"%s",PROGNAME);
  747.    fprintf(file,"</PROGRAM>\n");
  748.    fprintf(file,"  <MARKNAME>");
  749.    fprintf(file,"%s",MARKNAME);
  750.    fprintf(file,"</MARKNAME>\n");
  751.    fprintf(file,"</MARK>\n");
  752.   }
  753.